home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / SRS / client / install.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2000-01-12  |  4.3 KB  |  175 lines

  1. #! /bin/sh
  2. #
  3. # This script is to setup and install SRS on your system
  4. #
  5. # It creates (or uses) a non-root user so that you don't risk having 
  6. # super-user privileges abused
  7. #
  8. # -------------------------------------------------------
  9.  
  10. echo -e "\nSRS by RepSec, Inc. (RSI)"
  11. echo -e "-------------------------\n"
  12.  
  13. # -------------------------------------------------------
  14. #
  15. # Make sure this is run as root (uid 0)
  16.  
  17. ID="`id -a | cut -d' ' -f1 | cut -d'=' -f2 | cut -d'(' -f1`"
  18.  
  19. if [ $ID != "0" ]
  20. then
  21.    echo "This script must be run as root"
  22.    exit
  23. fi
  24.  
  25. # -------------------------------------------------------
  26. #
  27. # Find out which non-root user to run SRS with
  28.  
  29. echo -n "Enter a non-root user for SRS to use [srs]: "
  30. read username
  31.  
  32. if [ -z $username ] 
  33. then
  34.    username="srs"
  35.    echo "Attempting to add user \"$username\" to the system..."
  36.  
  37. else
  38.    echo -e "\nAttempting to add user \"$username\" to the system..."
  39.  
  40. fi
  41.  
  42. # -------------------------------------------------------
  43. #
  44. # See if the user already exists
  45.  
  46. if [ -n "`grep "^$username:" /etc/passwd`" ] 
  47. then
  48.    echo -e "User \"$username\" already exists.. continuing\n"
  49.  
  50.    echo "# This was generate automatically be SRS install.sh" > /etc/SRS.user
  51.    echo -e "# Do not modify\n" >> /etc/SRS.user
  52.  
  53.    echo "$username" >> /etc/SRS.user
  54.  
  55.    if [ -d "/var/log" ]
  56.    then
  57.       echo "Installing SRS certificates into /var/log/SRS/certs"
  58.       mkdir /var/log/SRS 2>/dev/null
  59.       mkdir /var/log/SRS/certs 2>/dev/null
  60.       rm -f /var/log/SRS/certs/* 2>/dev/null
  61.  
  62.       cp -f certs/* /var/log/SRS/certs
  63.       cp -f ../certs/* /var/log/SRS/certs
  64.  
  65.    elif [ -d "/var/adm" ]
  66.    then
  67.       echo "Installing SRS certificates into /var/adm/SRS/certs"
  68.       mkdir /var/adm/SRS 2>/dev/null
  69.       mkdir /var/adm/SRS/certs 2>/dev/null
  70.       rm -f /var/adm/SRS/certs/* 2>/dev/null
  71.  
  72.       cp -f certs/* /var/adm/SRS/certs
  73.       cp -f ../certs/* /var/adm/SRS/certs
  74.  
  75.    elif [ -d "/usr/adm" ]
  76.    then
  77.       echo "Installing SRS certificates into /usr/adm/SRS/certs"
  78.       mkdir /usr/adm/SRS 2>/dev/null
  79.       mkdir /usr/adm/SRS/certs 2>/dev/null
  80.       rm -f /usr/adm/SRS/certs/* 2>/dev/null
  81.  
  82.       cp -f certs/* /usr/adm/SRS/certs
  83.       cp -f ../certs/* /usr/adm/SRS/certs
  84.  
  85.    fi
  86.  
  87.    make install
  88.  
  89.    echo -ne "\nSRS setup is now complete. "
  90.    echo -e "Please type 'make install' and read SRS docs.\n"
  91.  
  92.    exit
  93.  
  94. fi
  95.  
  96. # -------------------------------------------------------
  97. #
  98. # Create the user using "useradd" or "adduser" depending on your system
  99.  
  100. if [ -f "/etc/shadow" ]
  101. then
  102.    addcmd="usersadd"
  103.    addcmd1="adduser"
  104.  
  105. else
  106.    addcmd="adduser"
  107.    addcmd1="useradd"
  108.  
  109. fi
  110.  
  111. if [ "`which $addcmd | cut -c1-9`" != "which: no" ]
  112. then
  113.    echo -e "Attempting to add the user with the '$addcmd' command.\n"
  114.    `which $addcmd` "$username"
  115.  
  116. elif [ "`which $addcmd1 | cut -c1-9`" != "which: no" ]
  117. then
  118.    echo -e "Attempting to add the user with the '$addcmd1' command.\n"
  119.    `which $addcmd1` "$username"
  120.  
  121. else
  122.    echo -e "\nNo commands to add users were found."
  123.    echo -e "Please add user \"$username\" to the system manually" \
  124.            "and then re-run this script.\n"
  125.  
  126.    exit
  127.  
  128. fi
  129.  
  130. # -------------------------------------------------------
  131. #
  132. # SRS binary will check this file to find out which non-root user to use
  133.  
  134. echo    "# This was generate automatically be SRS install.sh" > /etc/SRS.user
  135. echo -e "# Do not modify\n" >> /etc/SRS.user
  136.  
  137. echo "$username" >> /etc/SRS.user
  138.  
  139. if [ -d "/var/log" ]
  140. then
  141.    echo "Installing SRS certificates into /var/log/SRS/certs"
  142.    mkdir /var/log/SRS 2>/dev/null
  143.    mkdir /var/log/SRS/certs 2>/dev/null
  144.    rm -f /var/log/SRS/certs/* 2>/dev/null
  145.  
  146.    cp -f certs/* /var/log/SRS/certs 2>/dev/null
  147.    cp -f ../certs/* /var/log/SRS/certs 2>/dev/null
  148.  
  149. elif [ -d "/var/adm" ]
  150. then
  151.    echo "Installing SRS certificates into /var/adm/SRS/certs"
  152.    mkdir /var/adm/SRS 2>/dev/null
  153.    mkdir /var/adm/SRS/certs 2>/dev/null
  154.    rm -f /var/adm/SRS/certs/* 2>/dev/null
  155.  
  156.    cp -f certs/* /var/adm/SRS/certs
  157.    cp -f ../certs/* /var/adm/SRS/certs
  158.  
  159. elif [ -d "/usr/adm" ]
  160. then
  161.    echo "Installing SRS certificates into /usr/adm/SRS/certs"
  162.    mkdir /usr/adm/SRS 2>/dev/null
  163.    mkdir /usr/adm/SRS/certs 2>/dev/null
  164.    rm -f /usr/adm/SRS/certs/* 2>/dev/null
  165.  
  166.    cp -f certs/* /usr/adm/SRS/certs
  167.    cp -f ../certs/* /usr/adm/SRS/certs
  168.  
  169. fi
  170.  
  171. make install
  172. echo -e "\nSRS setup is now complete. Please read SRS.doc.\n"
  173.  
  174. exit
  175.